package com.ctsi.ssdc.config;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("可视化数据接口")
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ctsi.ssdc.controller"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(new ApiInfoBuilder()
                        .title("数据可视化")
                        .description("旅游数据中心")
                        .version("1.0")
                        .contact(new Contact("ris","https:www.baidu.com","****@qq.com")
                        )
                        .license("The Apache License")
                        .licenseUrl("https:www.baidu.com")
                        .build());
    }

    @ApiModel
    public static class Page {
        @ApiModelProperty(value = "第page页,从0开始计数", example = "0")
        private Integer page;

        @ApiModelProperty(value = "每页数据数量", example = "10")
        private Integer size;

        @ApiModelProperty("按这种格式写：GET /path/all?size=100&page=3&sort=id,asc&sort=name,desc")
        private List<String> sort;

        public Integer getPage() {
            return page;
        }

        public void setPage(Integer page) {
            this.page = page;
        }

        public Integer getSize() {
            return size;
        }

        public void setSize(Integer size) {
            this.size = size;
        }

        public List<String> getSort() {
            return sort;
        }

        public void setSort(List<String> sort) {
            this.sort = sort;
        }
    }
}
